package com.xjgc.msibase.quartz.job;

import com.xjgc.msibase.service.IMsiServerRecordService;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.SpringContextUtils;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

/**
 * 中间库记录清理
 *
 * @author: 小逗号
 * @date: 2023-11-21
 * @description:
 * @since:
 */
@Slf4j
public class RecordClearJob implements Job {
    private static IMsiServerRecordService msiServerRecordService;

    private IMsiServerRecordService getRecordService() {
        if (RecordClearJob.msiServerRecordService == null) {
            RecordClearJob.msiServerRecordService = SpringContextUtils.getBean(IMsiServerRecordService.class);
        }
        return RecordClearJob.msiServerRecordService;
    }

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        log.info(" Job Execution key：" + jobExecutionContext.getJobDetail().getKey());
        log.info("中间库记录,记录明细定时清理,只保留一月内记录.");
        IMsiServerRecordService recordService = this.getRecordService();
        recordService.deleteTimer();
        log.info(" Job Execution key：" + jobExecutionContext.getJobDetail().getKey() + "执行完成!");

    }

}
